<template>
  <div class="page-header-index-wide">
    <a-row>
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="月新增会员统计" :style="{ marginTop: '24px' }">
          <a-row>
            <a-col style="margin:0px auto; text-align: center;font-size:15px;font-weight:700;">
              新增会员月统计(总计:
              <span v-text="total"></span>)
            </a-col>
          </a-row>
          <line-chart-multid :fields="visitFields" :dataSource="visitInfo"></line-chart-multid>
        </a-card>
      </a-col>
    </a-row>

    <table
      id="table_report"
      class="table table-striped table-bordered table-hover"
      style="margin-top:10px;"
    >
      <thead>
        <tr>
          <th>序号</th>
          <th>注册月份</th>
          <th>新增会员</th>
        </tr>
      </thead>

      <tbody v-for="(value,key,index) in visitInfoD" v-bind:key="key">
        <tr>
          <td>{{key+1}}</td>
          <td>{{value.type}}</td>
          <td>{{value.count}}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import LineChartMultid from '@/components/chart/LineChartMultid'
import Trend from '@/components/Trend'
import { getLoginfo, getVisitInfo, getDataInfo } from '@/api/api'

export default {
  name: 'Analysis',
  components: {
    LineChartMultid
  },
  data() {
    return {
      loading: true,
      center: null,
      loginfo: {},
      total: '',
      visitFields: ['count'],
      visitInfo: [],
      visitInfoD: [],
      indicator: <a-icon type="loading" style="font-size: 24px" spin />
    }
  },
  created() {

    this.initLogInfo()
  },
  methods: {
    initLogInfo() {
      getDataInfo().then(res => {
        if (res.code == 200 || res.success) {
          if (!!res.data) {
            this.loading = false
            this.visitInfo = res.data.list
            this.total = res.data.totalAll
            this.visitInfoD = res.data.listD
          } else if (!!res.result) {
            this.loading = false
            this.visitInfo = res.result.list
            this.total = res.result.totalAll
            this.visitInfoD = res.result.listD
          }
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.circle-cust {
  position: relative;
  top: 28px;
  left: -100%;
}
.extra-wrapper {
  line-height: 55px;
  padding-right: 24px;

  .extra-item {
    display: inline-block;
    margin-right: 24px;

    a {
      margin-left: 24px;
    }
  }
}

/* 首页访问量统计 */
.head-info {
  position: relative;
  text-align: left;
  padding: 0 32px 0 0;
  min-width: 125px;

  &.center {
    text-align: center;
    padding: 0 32px;
  }

  span {
    color: rgba(0, 0, 0, 0.45);
    display: inline-block;
    font-size: 0.95rem;
    line-height: 42px;
    margin-bottom: 4px;
  }
  p {
    line-height: 42px;
    margin: 0;
    a {
      font-weight: 600;
      font-size: 1rem;
    }
  }
}
</style>